<?php


namespace app\api\controller\v1;


use app\api\model\Theme;
use app\api\validate\IdCollection;
use app\api\validate\IDMustBePostivelnt;
use app\lib\exception\complexException;
use app\lib\exception\themeException;

class ThemeController{

    public function getSimpleList($ids=''){
        (new IdCollection())->goCheck();
        $ids = explode(',',$ids);
        $themeModel = new Theme();
        $list = $themeModel::getTheme($ids);
//        if($list->isEmpty()){
//            throw new themeException();
//        }



//        $themeModel = new Theme();
//        $list = $themeModel->getTheme($ids);
        return json($list);
    }

    //获取详情
    public function getComplexOne($id){
        (new IDMustBePostivelnt())->goCheck();
        $themeModel = new Theme();
        $list = $themeModel::getThemeWithProducts($id);

//        $themeModel = new Theme();
//        $list = $themeModel->getThemeWithProducts($id);

        if(!$list){
            throw new complexException();
        }

        return json($list);
    }

}





